package com.iengine.services.api.command.chat;

import java.util.HashMap;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;

import com.google.gson.Gson;
import com.iengine.services.api.utils.Constant;
import com.ingine.data.pojo.HReply;

@SuppressWarnings({"unchecked","rawtypes"})
public class CommandJokeTxt extends AbstractTxtPhoneApiCommand{

	public static final String FIELD_JOKE_TYPE = "jokeType";

	/**
	 *ClassName[String]:CommandJoke
	 *	arg-list:
	 *	JokeType[String]:冷笑话
	 */
	@Override
	protected Map formatArgs(Map map, Map nlpParams) {
		HReply reply = getRemoteData(map, nlpParams);
		map = this.getFormatResult(reply,map);
		return map;
	}
	
	protected Map getFormatResult(HReply reply,Map map){
		map = addValue(map,isDirectReturn(), reply.getContent());
		return map;
	}
	
	public String processQuery(Map map,Map nlpParams){
		Map temp = new HashMap<String, Object>();
		temp.putAll(nlpParams);
    	Object dataSize = map.get(Constant.FIELD_DATASIZE);
    	if(null != dataSize){
    		temp.putAll((Map)dataSize);
    	}
	    Map parameterMap=new HashMap();
	    temp.put(FIELD_JOKE_TYPE, "txt");
		parameterMap.put(Constant.DATA_TYPE_FIELD, Constant.JOKE_FIELD);
		parameterMap.put(Constant.PARAMS_DATA_FIELD, temp);
		return new Gson().toJson(parameterMap);
	}

}
